package com.testapp.bluetoothtest08.cipher;


import com.testapp.bluetoothtest08.cipher.entity.JoinCheckStr;
import com.testapp.bluetoothtest08.cipher.entity.ScanCodeFirstRequest;
import com.testapp.bluetoothtest08.cipher.entity.ScanCodeSecondRequest;
import com.testapp.bluetoothtest08.cipher.entity.UserJoin;
import com.testapp.bluetoothtest08.cipher.entity.UserLog;
import com.testapp.bluetoothtest08.cipher.entity.UserUpdate;

/**
 * 服务端
 */
public interface GMService {

    /**
     * 用户注册
     * @param user
     * @return null 验证失败
     *         JoinCheckStr 验证成功并返回给前端
     */
    JoinCheckStr userJoin(UserJoin user);

    /**
     * 用户验证第一次请求，存储用户数据并返回challenge
     * @param user
     * @return challenge
     */
    String scanCodeFirst(ScanCodeFirstRequest user);

    /**
     * 验证用户请求数据正确性
     * @param requestFirst
     * @param requestSecond
     * @param challenge
     * @return 返回UserLog对象即是正常登陆，记录UserLog对象
     *         返回TrackParameter对象，重放攻击
     *         抛出异常，验证未通过
     */
    public Object scanCodeSecond(ScanCodeFirstRequest requestFirst , ScanCodeSecondRequest requestSecond, String challenge, UserLog userLog);

    public boolean scanCodeSecondJustCheck(ScanCodeFirstRequest requestFirst, ScanCodeSecondRequest requestSecond, String challenge);

    UserUpdate genenrateUpdateLog(ScanCodeFirstRequest request);

}
